//
//  CALayer+Animate.m
//  分享demo
//
//  Created by pc-chtypd056 on 2018/8/23.
//  Copyright © 2018年 CTL. All rights reserved.
//

#import "CALayer+Animate.h"

@implementation CALayer (Animate)

- (void)scale{
    CAKeyframeAnimation *kfa = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    kfa.duration = 0.3;
    kfa.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 0.8)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.1)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];
    kfa.removedOnCompletion = YES;
    [self addAnimation:kfa forKey:@"scale"];
}

- (void)dissmissScale:(dispatch_block_t)complete{
    CAKeyframeAnimation *kfa = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
    kfa.duration = 0.3;
    kfa.values = @[[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.8, 0.8, 0.8)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.1, 1.1, 1.1)],[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.001, 0.001, 0.001)]];
    kfa.removedOnCompletion = YES;
    [self addAnimation:kfa forKey:@"dissmissScale"];
    if (complete) {
        complete();
    }
}

@end
